#pragma once
#include "Astronomy/Coordinate.hpp"
#include <array>

// > 总岁差(general precession) => 由赤道岁差和黄道岁差组成
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// > 章动(nutation)
//   -> 黄经章动(NutationInEcliptic)
//         - 描述：在黄道上的分量;
//         - 符号：λ(lamdba),
//         - 起点：春分点
//         - 单位：度，更小的单位是“角分”和“角秒”
//         - 范围：[0°，360°] 由西向东量度
//   -> 交角章动(NutationInObliquity) 
//         - 描述：因日月章动引起的黄赤交角的改变量;
//         - 符号：β(bata),
//         - 起点：黄经圈
//         - 单位：度，更小的单位是“角分”和“角秒”
//         - 范围：[-90°, +90°]北黄极为+90°，南南极为-90°(向北为正，向南为负)
// ---------------------------------------------------------------------------------------------------------------------------------------------------------

//章动值
struct NutationAngles
{
    //黄经章动;
    double longitude;
    //交角章动;
    double obliquity;
};

// 高精度章动系数;//IAU2000B;
struct HighNutationCoefficient
{
    double M;
    double Mprime;
    double F;
    double D;
    double omega;
    double sincoeff1;
    double sincoeff2;
    double sincoeff3;
    double coscoeff1;
    double coscoeff2;
    double coscoeff3;
};
// 中精度章动系数;
struct MediumNutationCoefficient
{
    double T;
    double T1;
    double T2;
    double sincoeff1;
    double coscoeff1;
};

class CNutation
{
    CNutation() = delete;
    ~CNutation() = delete;

     //当前使用的是 IAU2000B 表;
    static const std::array<HighNutationCoefficient, 77>  HighNutationTable;
    static const std::array<MediumNutationCoefficient,10> MediumNutationTable;

public:


    /**
     * 计算高精度章动;
     * nutation(t,zq)
     * 
     * @param T
     *            儒略世纪数;
     * @param NumberOfCycleDays
     *            周期数：表示只计算周期大于NumberOfCycleDays(天)的项;
     * @return 章动值 @see NutationAngles
     */
    static NutationAngles HighPrecision(double T, const int NumberOfCycleDays = 0) noexcept;
    /**
     * 计算中精度章动;
     * nutation2(t)
     * 
     * @param T
     *            儒略世纪数;
     * @return 章动值 @see NutationAngles
     */
    static NutationAngles MediumPrecision(double T) noexcept;
    /**
     * 计算中精度章动-黄经 ;
     * nutationLon2(t)
     *
     * @param T
     *            儒略世纪数;
     * @return 章动值 @see NutationAngles
     */
    static double MediumPrecisionLongitude(double T) noexcept;
    /*
    * 本函数计算赤经章动及赤纬章动;
    *  @param equator
    *            赤道坐标;
    * @param Epsilon
    *            黄赤交角;
    * @param nutation
    *            章动值;
    * 
    * @return 修正后的赤道坐标
    */
    static Coordinate3D EquatorNutation(const Coordinate3D& equator,const double Epsilon, const NutationAngles & nutation) noexcept;

};


